// Implementation of Monotone Chain Convex Hull algorithm.
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
 
typedef long long CoordType;
 
struct Point {
	CoordType x, y;
 
	bool operator <(const Point &p) const {
		return x < p.x || (x == p.x && y < p.y);
	}
};
 
// 2D cross product.
// Return a positive value, if OAB makes a counter-clockwise turn,
// negative for clockwise turn, and zero if the points are collinear.
CoordType cross(const Point &O, const Point &A, const Point &B)
{
	return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}
 
// Returns a list of points on the convex hull in counter-clockwise order.
// Note: the last point in the returned list is the same as the first one.
vector<Point> convexHull(vector<Point> P)
{
	int n = P.size(), k = 0;
	vector<Point> H(2*n);
 
	// Sort points lexicographically
	sort(P.begin(), P.end());
 
	// Build lower hull
	for (int i = 0; i < n; i++) {
		while (k >= 2 && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
 
	// Build upper hull
	for (int i = n-2, t = k+1; i >= 0; i--) {
		while (k >= t && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
 
	H.resize(k);
	return H;
}

int main()
{
       int n;
       while(cin >> n && n != 0)
       {
               vector<Point> v, h;
               for(int i = 0; i < n; i++)
               {
							Point newpoint;
                       cin >> newpoint.x >> newpoint.y;
							  v.push_back(newpoint);
               }
               h = convexHull(v);
					h.pop_back();
               
               cout << h.size() << endl; //size of convex hull
               for(int i = 0; i < h.size(); i++)
                       cout << h[i].x << " " << h[i].y << endl;  //points in hull
               cout << endl;
       }
       return 0;
}
